# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python
from cerbero.tools.libtool import LibtoolLibrary

class Recipe(recipe.Recipe):
    name = 'libnice'
    version = '0.1.16'
    stype = SourceType.TARBALL
    btype = BuildType.MESON
    url = 'https://nice.freedesktop.org/releases/%(name)s-%(version)s.tar.gz'
    tarball_checksum = '06b678066f94dde595a4291588ed27acd085ee73775b8c4e8399e28c01eeefdf'
    # Either LGPL-2.1+ or MPL-1.1
    licenses = [License.LGPLv2_1Plus, License.MPLv1_1]
    meson_options = {'tests' : 'disabled',
                     'gupnp' : 'disabled',
                     'gstreamer' : 'enabled',
                     'crypto-library' : 'gnutls'}
    deps = ['glib', 'gstreamer-1.0', 'gnutls']
    patches = []

    files_bins = ['stunbdc', 'stund']
    files_libs = ['libnice']
    files_devel = [
        'include/nice',
        'include/stun',
        'lib/pkgconfig/nice.pc',
    ]
    files_plugins_net = ['lib/gstreamer-1.0/libgstnice%(mext)s']
    files_plugins_net_devel = [
        'lib/gstreamer-1.0/libgstnice.a', 'lib/gstreamer-1.0/libgstnice.la',
    ]
    # FIXME - if_arp.h? (iOS)

    def post_install (self):
        nice_deps = ['gio-2.0', 'gthread-2.0', 'gnutls']
        lib = LibtoolLibrary('nice', None, None, None, self.config.libdir,
                self.config.target_platform, deps=nice_deps)
        lib.save()
        lib = LibtoolLibrary('gstnice', None, None, None, os.path.join(self.config.libdir, 'gstreamer-1.0'),
                self.config.target_platform, deps=(nice_deps + ['nice', 'gstbase-1.0']))
        lib.save()
        super().post_install()
